<?php
namespace app\common\model;

use think\Model;

class Gameagent extends Model
{
    protected $connection = 'db_config_aiqi';
	public static function getInfo($aid="",$gid="")
	{
	    if(!is_numeric($aid)) 	return 0;
	    if(!is_numeric($gid))	return 0;
	    $data=Gameagent::where([['cid','=',$aid],['gid','=',$gid]])->find();
		return $data;
	}
    function getAgentlist($cid)
    {
        // 关联Gamelist模型，只查询name字段
        $data= $this->where(['cid'=>$cid,'status'=>1])
            ->with(['gamelist' => function($query) {
            $query->field('id,name'); // 必须包含id字段用于关联
        }])->order('id desc')
        ->select();
        return $data;
    }

	public function gamelist()
	{
		return $this->belongsTo('Gamelist', 'gid', 'id');
	}

}